package com.everest.tribalapp;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

public class Home extends Activity
{

	private LinearLayout home;
	private LinearLayout add;
	private LinearLayout setting;
	private LinearLayout logout;
	private TextView username;
	private TextView dat;
	@Override
	public void onBackPressed() 
	{
		
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		Home.this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.home);
		home=(LinearLayout)findViewById(R.id.home_home);
		add=(LinearLayout)findViewById(R.id.home_add);
		setting=(LinearLayout)findViewById(R.id.home_setting);
		username=(TextView)findViewById(R.id.home_username);
		username.setText(Global.username);
		dat=(TextView)findViewById(R.id.home_date);
		Calendar c = Calendar.getInstance();
		SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
		String formattedDate = df.format(c.getTime());
		dat.setText(formattedDate);
		Global.date=dat.getText().toString().trim();
		logout=(LinearLayout)findViewById(R.id.home_logout);
		if(Global.i==0)
		{
		startService(new Intent(Home.this,Myservices.class));
		startService(new Intent(Home.this,Myservices1.class));
		startService(new Intent(Home.this,Myservices2.class));
		Global.i=1;
		}
		logout.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) 
			{
				// TODO Auto-generated method stub
			AlertDialog.Builder builder=new AlertDialog.Builder(Home.this);
			builder.setTitle("Logout!!!")
			.setMessage("Are You Sure To Want To Logout?")
			.setPositiveButton("yes",new DialogInterface.OnClickListener()
			{
				public void onClick(DialogInterface dialog,int id)
				{
					Intent intent1=new Intent(getApplicationContext(),Login.class);
					startActivity(intent1);
					
					Home.this.finish();
				}
			  }).setNegativeButton("NO",new DialogInterface.OnClickListener()
			  {
					public void onClick(DialogInterface dialog,int id) 
					{
						
					}
				  }).show();
			}
		});
		add.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			Intent intent1=new Intent(getApplicationContext(),Add1.class);
			startActivity(intent1);
			Home.this.finish();
			}
		});
		
		setting.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			Intent intent1=new Intent(getApplicationContext(),Setting.class);
			startActivity(intent1);
			Home.this.finish();
			}
		});
	}

}
